package com.xfsong.demo.config;

import com.xfsong.demo.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //JWT拦截器
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("/api/**") // 拦截所有以 /api 开头的请求
                .excludePathPatterns("/api/members/login"); // 排除 /api/login 接口，允许匿名访问
    }
}
